package com.example.sb.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.sb.dao.UserDao;
import com.example.sb.entity.User;
import com.example.sb.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * (User)表服务实现类
 *
 * @author junjin.zhao
 * @since 2021-12-12 08:58:39
 */
@Service("userService")
public class UserServiceImpl extends ServiceImpl<UserDao, User> implements UserService {

    @Autowired
    private UserDao userDao;


    @Override
    public int insertBatch() {
        List<User> entities = new ArrayList<>();
        for(int i = 0;i<1000000;i++){
            User user = new User();
            user.setId(i);
            user.setName("用户"+i);
            user.setPassword(String.valueOf(i));
            entities.add(user);
        }
        return userDao.insertBatch(entities);
    }
}

